package actions;

import model.QueryResult;
import persistence.VadeMecumMultimediaDAO;

import com.opensymphony.xwork2.ActionSupport;

public class QueryForFilePropertyAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private String fileId;

	private String fileProperty;

	private QueryResult result;
	
	public String execute() throws Exception {
		try {
			//TODO Essa resposta deve ser um String realmente?!			
			result = VadeMecumMultimediaDAO.getInstance().getFileProperty(Integer.parseInt(getFileId()), getFileProperty());		
			System.out.println(">>> Query result: " + result);			
		} catch (Exception e) {
			e.printStackTrace();
			addActionError(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	public String getFileId() {
		return fileId;
	}

	public void setFileId(String fileId) {
		this.fileId = fileId;
	}

	public String getFileProperty() {
		return fileProperty;
	}

	public void setFileProperty(String fileProperty) {
		this.fileProperty = fileProperty;
	}

	public QueryResult getResult() {
		return result;
	}

	public void setResult(QueryResult result) {
		this.result = result;
	}	
}